home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-30 | 6.0 KB | 248 lines | [TEXT/KAHL] |
- /******************************************************************************
- x_CApp.cp
-
- CApp "Lower-Layer" Application Class
-
- Copyright © 1994 My Software Inc. All rights reserved.
-
- Generated by Visual Architectâ„¢ 9:40 PM Wed, Jun 8, 1994
-
- This file is rewritten each time you generate code. You should not
- make changes to this file; changes should go in the CApp.cp
- file, instead.
-
- If you want to change how Visual Architect generates this file, you can
- change the template for this file. It is "_App_cp" in the Visual Architect
- Templates folder.
-
- ******************************************************************************/
-
- #include "x_CApp.h"
-
- #include "CApp.h"
-
- #include "References.h"
- #include "CMain.h"
- #include <CBartender.h>
- #include <Commands.h>
- #include <CDesktop.h>
- #include <CFile.h>
- #include <CFWDesktop.h>
- #include <CList.h>
- #include <Packages.h>
- #include <TBUtilities.h>
- #include <TCLForceReferences.h>
-
- #include "CDisplayPane.h"
- #include "CMain.h"
-
- extern OSType gSignature; /* Creator for Application's files */
- extern CBartender *gBartender; /* Manages all menus */
- extern CDesktop *gDesktop; /* The visible Desktop */
-
- #define ALRTabout 500
-
-
- TCL_DEFINE_CLASS_M1(x_CApp, CApplication);
-
- /**** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ****/
-
-
- /******************************************************************************
- Ix_CApp
-
- Initialize an Application.
- ******************************************************************************/
-
- void x_CApp::Ix_CApp(short extraMasters, Size aRainyDayFund,
- Size aCriticalBalance, Size aToolboxBalance)
-
- {
- IApplication(extraMasters, aRainyDayFund, aCriticalBalance, aToolboxBalance);
- }
-
-
- /******************************************************************************
- SetUpFileParameters {OVERRIDE}
-
- Specify the kinds of files your application opens
- ******************************************************************************/
-
- void x_CApp::SetUpFileParameters()
- {
- CApplication::SetUpFileParameters();
-
- // File types as defined in CApp.h
-
- sfNumTypes = kNumFileTypes;
- sfFileTypes[0] = kFileType1;
- sfFileTypes[1] = kFileType2;
- sfFileTypes[2] = kFileType3;
- sfFileTypes[3] = kFileType4;
- gSignature = 'cApp';
- }
-
-
- /******************************************************************************
- SetUpMenus {OVERRIDE}
-
- Set up the menus after first creating any floating/tearoff
- windows. The latter must be done before the bartender inits.
- ******************************************************************************/
-
- void x_CApp::SetUpMenus()
- {
-
- CApplication::SetUpMenus();
- }
-
-
- /******************************************************************************
- ForceClassReferences {OVERRIDE}
-
- Reference classes that might do object I/O.
- ******************************************************************************/
-
- void x_CApp::ForceClassReferences(void)
-
- {
- CApplication::ForceClassReferences();
-
- /* From References.c */
- ReferenceStdClasses(); /* See template file Ref */
-
- TCL_FORCE_REFERENCE(CDisplayPane);
- }
-
-
- /**** C O M M A N D M E T H O D S ****/
-
-
- /******************************************************************************
- DoCommand {OVERRIDE}
-
- Handle application commands
- ******************************************************************************/
-
- void x_CApp::DoCommand(long theCommand)
-
- {
- switch (theCommand)
- {
- case cmdAbout:
-
- // Simple About alert. Subclasses will probably
- // trap this command to do something sexier.
-
- PositionDialog('ALRT', ALRTabout);
- InitCursor();
- ParamText("\pCApp", "\pMy Software Inc", "\p", "\p");
- Alert(ALRTabout, NULL);
- break;
-
- default:
- CApplication::DoCommand(theCommand);
- break;
- }
- }
-
-
- /**** D O C U M E N T M E T H O D S ****/
-
-
- /******************************************************************************
- CreateDocument {OVERRIDE}
-
- Make a new document when user chooses New from file menu.
- This method is entirely generic except for the document class.
- ******************************************************************************/
-
- void x_CApp::CreateDocument()
-
- {
- CDocument *volatile theDocument = NULL;
-
- theDocument = TCL_NEW(CMain,());
- TRY
- {
- ((CMain*) theDocument)->ICMain();
- theDocument->NewFile();
- }
- CATCH
- {
- ForgetObject(theDocument);
- }
- ENDTRY
- }
-
-
- /******************************************************************************
- OpenDocument {OVERRIDE}
-
- Open a document when user chooses Open from file menu.
- For multiple document types, this method assumes that each
- document is associated with a single file type.
- ******************************************************************************/
-
- void x_CApp::OpenDocument(SFReply *macSFReply)
-
- {
- CDocument *volatile theDocument = NULL;
-
- theDocument = TCL_NEW(CMain,());
- TRY
- {
- ((CMain*) theDocument)->ICMain();
- theDocument->OpenFile(macSFReply);
- }
- CATCH
- {
- ForgetObject(theDocument);
- }
- ENDTRY
- }
-
-
-
-
- /******************************************************************************
- FileAlreadyOpen
-
- If file already in use return TRUE and bring owning document's
- window to the foreground. Sent from document before opening.
- ******************************************************************************/
-
- static Boolean EqualFile(CDirector *obj, long param)
- {
- FSSpec theFileSpec;
- CFile *theFile;
- FSSpec *theParam = (FSSpec*) param;
-
- if (member(obj, CDocument))
- {
- theFile = ((CDocument*)obj)->itsFile;
- if (theFile == NULL)
- return FALSE;
- theFile->GetFSSpec(&theFileSpec);
- return theFileSpec.vRefNum == theParam->vRefNum
- && theFileSpec.parID == theParam->parID
- && !IUEqualString(theFileSpec.name, theParam->name);
- }
- return FALSE;
- }
-
- Boolean x_CApp::FileAlreadyOpen(
- CFile *aFile)
-
- {
- FSSpec fileSpec;
- CDirector *theDirector = NULL;
-
- aFile->GetFSSpec(&fileSpec);
- if (itsDirectors) /* Search for matching file */
- theDirector = (CDirector*) itsDirectors->FindItem1(EqualFile, (long) &fileSpec);
- if (theDirector) /* If find one, bring to front */
- theDirector->GetWindow()->Select();
- return theDirector != NULL; /* Tell caller */
- }
-